package com.study.springcloud.serivce;

import com.study.springcloud.config.FeignConfiguration;
import com.study.springcloud.response.ResultObject;
import com.study.springcloud.serivce.fallback.GoodsRemoteClientFallback;
import com.study.springcloud.serivce.fallback.GoodsRemoteClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @Author Chen Jie
 * @Date 2022/3/7 16:31
 * @Version 1.0
 */
@Component
@FeignClient(
        value = "springcloud-service-goods",
//        fallback = GoodsRemoteClientFallback.class
        fallbackFactory = GoodsRemoteClientFallbackFactory.class,
        configuration = {FeignConfiguration.class}
)
public interface GoodsRemoteClient {
    //使用Feign组件可以减少代码, 底层通过RestTemplate调用服务名+URI(带有Ribbon的负载均衡)
    @GetMapping("/service/goods")
    ResultObject goods();
}
